package com.ruoyi.business.base.controller;

import com.ruoyi.business.base.domain.AcceptStandard;
import com.ruoyi.business.base.service.IAcceptStandardService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 验收标准Controller
 *
 * @author lcy
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/base/acceptStandard")
@Api(tags = "验收标准相关接口")
public class AcceptStandardController extends BaseController {

    @Autowired
    private IAcceptStandardService acceptStandardService;

    /**
     * 查询验收标准列表
     */
    @RequiresPermissions("base:acceptStandard:list")
    @GetMapping("/list")
    @ApiOperation("查询验收标准列表")
    @Log(value = "查询验收标准列表")
    public TableDataInfo list(AcceptStandard acceptStandard) {
        startPage();
        List<AcceptStandard> list = acceptStandardService.selectAcceptStandardList(acceptStandard);
        return getDataTable(list);
    }

    /**
     * 导出验收标准列表
     */
    @RequiresPermissions("base:acceptStandard:export")
    @Log(title = "验收标准", businessType = BusinessType.EXPORT,value = "导出验收标准列表")
    @PostMapping("/export")
    @ApiOperation("导出验收标准列表")
    public void export(HttpServletResponse response, AcceptStandard acceptStandard) {
        List<AcceptStandard> list = acceptStandardService.selectAcceptStandardList(acceptStandard);
        ExcelUtil<AcceptStandard> util = new ExcelUtil<AcceptStandard>(AcceptStandard.class);
        util.exportExcel(response, list, "验收标准数据");
    }

    /**
     * 获取验收标准详细信息
     */
    @RequiresPermissions("base:acceptStandard:query")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取验收标准详细信息")
    @Log(value = "获取验收标准详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(acceptStandardService.selectAcceptStandardById(id));
    }

    /**
     * 新增验收标准
     */
    @RequiresPermissions("base:acceptStandard:add")
    @Log(title = "验收标准", businessType = BusinessType.INSERT,value = "新增验收标准")
    @PostMapping("/insert")
    @ApiOperation("新增验收标准")
    public AjaxResult add(@RequestBody AcceptStandard acceptStandard) {
        return toAjax(acceptStandardService.insertAcceptStandard(acceptStandard));
    }

    /**
     * 修改验收标准
     */
    @RequiresPermissions("base:acceptStandard:edit")
    @Log(title = "验收标准", businessType = BusinessType.UPDATE,value = "修改验收标准")
    @PutMapping("/update")
    @ApiOperation("修改验收标准")
    public AjaxResult edit(@RequestBody AcceptStandard acceptStandard) {
        return toAjax(acceptStandardService.updateAcceptStandard(acceptStandard));
    }

    /**
     * 删除验收标准
     */
    @RequiresPermissions("base:acceptStandard:remove")
    @Log(title = "验收标准", businessType = BusinessType.DELETE,value = "删除验收标准")
	@DeleteMapping("/delete/{ids}")
    @ApiOperation("删除验收标准")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(acceptStandardService.deleteAcceptStandardByIds(ids));
    }
}
